from multiprocessing import Process
import requests
import random

from gen import *

captchaURL = "https://5eroyal.com/auth.php"
dicFilePath = r"./passDic.txt"
# proxy = {"http": "socks5://127.0.0.1:10808"}
proxy = None
cookies = {
    "3941ddf92f1f50fe8180ec7043c1892d": "ypv3j07nqj0ds6yyg1v8vz7xzm02",
    "4d859f85e3695eeb128ef56074bb7f7b": "kNnnNe08XC",
    "d64d864b7095cdf2eecaacf9dda77839": "b2403bfaee3a0e37838b83045a94790d",
    "timezoneOffset": "28800,0",
    "d89663b5b8aef145c0b3f978b548ec53": "jTG1VT2NWTnROYVU5VG9vZzlHalJ2YTM2TG8zVlM0SGJUVEhPZFR4U01LdV8tSlVPY19OdE5PU2FkaHozOU9pcTlLYzRkS1RsOXdOZ2NPSGw5T3o0Y2h2dTBuTkE5T2pfTl9wXzBCY19kX1VhZk9TYWRoMHUwT3ZwZEtUTzkxMG05d1RPMHdHTzlPbGE5MW9BZkJpQmRWTkVObmN1Tk9RX2pzVXE5Vk5FTm5jcU5PUV82SjU0YzRRcGY0M2diT3hhdkI5M0xUcElMNmxrYzYwZWprUUFMczhQTl9wXzBCMF9kbEVfNko1bmZPTm1kaEYzZDFVT2NoamFmS3YzY2hpQmNPYTRjMVRIY0s5bGR3MGdmSjNwMm52Xy1KVXYtNHptMG5UbmMxVWFkS3Y0MEJqTzBLVWEwQkYzZHdUTzlLRkIwQlNIMDR6My1reHk5bU5FTmxwSWZ3OW5mbmZsZDFjbWZoTnVmNEduZmhpcDA0VWFkaGZsYzFGNDl3OWE5aFl5djEza05fcF82Sj1nZktGQWZCOUhkd05wY25GQWZLRkFkMVVhZktpQWNPaTRmaFkzOWhZbWRWM3AybnZfLUpVdi1CYW05MU51OXdUbjkxejRmbmNnZk96QmNCaW0wNEdIZmgwZWM0R2Fjbk5BLWt4eTltTkVObHBJY25VTzl3emUwblNuZGhTbGZ3RmVmS0ZxOW4wcTBLOU9jS3hIOXdHX2NCMHl2MTNrTl9wXzZKNUgwSzBtY0tvcTluOW5jS1RIZktmT2QxTjRjbmZIZDF6dTBCZkgwT2NtMG0zcDJudl8tSlV2LUJVSGRLWWdmT3ozY2hVSGQxTmVkMVVfMDRjcGZPTmdmT29lZmh2bTl3MHAta3h5OW1ORU5scEk5MTlPZkIwcDluZmxjS3p1OUthQTloMGVmaG9nZjFUXzkxRjNkS1VsZkJ2eWJ3ZklObHVFTm5jQU5PUV82SjVJdjFUeWJ3U0I2SjVFMjRqODJfVTU%3D",
}
cookies = None
capCode = "qveq"


def hunt(pid):
    dic = open(dicFilePath, "r")
    passDic = [line.replace("\n", "") for line in dic.readlines()]
    while True:
        try:
            httpHeader = {
                # "Cache-Control": "max-age=0",
                "Origin": "https://5eroyal.com",
                # "Upgrade-Insecure-Requests": "1",
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.67",
                "Accept": "*/*",
                "Referer": "https://5eroyal.com/kNnnNe08XC/xqu0d57sj1/xtn97a3u0b?q=kNnnNe08XC&s=b2403bfaee3a0e37838b83045a94790d",
                "Accept-Encoding": "gzip, deflate, br",
                "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
                "ContentType": "application/x-www-form-urlencoded; charset=UTF-8",
                "alt-svc": 'h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400, h3=":443"; ma=86400,0',
                "dnt": "1",
                "sec-ch-ua": '" Not;A Brand";v="99", "Microsoft Edge";v="91", "Chromium";v="91"',
                "sec-ch-ua-mobile": "?0",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-origin",
            }

            # postData = {
            #     "name": genQQmail(),
            #     "pass": chooseAPass(passDic),
            #     "code": capCode,
            #     "face": randomServer(),
            #     "zone": randomDC(),
            #     "level": "幻想狂欢福袋",
            # }
            postData = {
                "doAuth": 1,
                "login": genMobileNum(),
                "password": chooseAPass(passDic),
            }
            r = requests.post(
                captchaURL,
                data=postData,
                cookies=cookies,
                headers=httpHeader,
                proxies=proxy,
            )
            # print(r.content)
            print(postData)
            print("hunt his mum once")
        except Exception:
            pass


if __name__ == "__main__":
    DEBUG = False
    if DEBUG:
        hunt(9999)
    else:
        procPool = []
        for p in range(48):
            p = Process(target=hunt, args=(p,))
            procPool.append(p)
            p.start()
